'use strict';

const {app, assert} = require('egg-mock/bootstrap');

describe('CollectApiTest', () => {
  let ctx;

  before(async function () {
    ctx = app.mockContext();
  });

  it('sugg', async () => {
    let kw = 'dd'
    const response = await ctx.curl(`https://www.baidu.com/sugrec?pre=1&p=3&ie=utf-8&json=1&prod=pc&from=pc_web&sugsid=33639,33744,33273,31254,33691,33855&wd=${kw}&req=2&csor=2&cb=jQuery1102020617794665700417_1617852533550&_=1617852533558`);
    const result = response.data.toString();


    let p = /(?:"q":"[^"]+)/g;
    let r = result.match(p);

    console.log(s);
    console.log('-----');

    let v = '"';

    for (let i = 1; i < r.length; i++) {
      let item = r[i].substr(5);
      console.log(item);
      v += `<div class=\\"acp\\" tabindex=\\"${i}\\">${r[i]}</div>`;
    }
    v += '"';


  }).timeout(60000);


});
